<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <!-- MOTW-DISABLED saved from url=(0014)about:internet -->
    <title>BirtMath</title>
    <link rel="StyleSheet" href="css/ScriptingReference.css" type="text/css" media="all" />
    <link rel="StyleSheet" href="css/webworks.css" type="text/css" media="all" />
    <link rel="StyleSheet" href="webworks.css" type="text/css" media="all" />
    <script type="text/javascript" language="JavaScript1.2">
      <!--
        var  WebWorksRootPath = "";
      // -->
    </script>
  </head>
  <body>
    <div style="text-align: left;">
      <table cellspacing="0" summary="">
        <tr>
          <td>
            <a href="ScriptingReference.24.5.html"><img src="images/prev.gif" alt="Previous" border="0" /></a>
          </td>
          <td>
            <a href="ScriptingReference.24.7.html"><img src="images/next.gif" alt="Next" border="0" /></a>
          </td>
        </tr>
      </table>
    </div>
    <hr align="left" />
    <blockquote>
      <h2 class="RH1_Class">Class  <a name="267940">BirtMath</a></h2>
      <p class="b_Body"><a name="267941">The BirtMath class provides functions to manipulate numeric data, for example, to add, subtract, multiple, divide, and round numbers. A number is a generic object that can be cast as another type in the Data Type field of the Edit Data Binding dialog. This class is static. The application cannot create instances of the class.</a></p>
      <h3 class="RH2_Method"><a name="267942">BirtMath.add</a></h3>
      <p class="b_Body"><a name="267943">This function returns the sum of two numbers.</a></p>
      <p class="N_sb_ScanBold"><a name="267944">Syntax</a></p>
      <div class="rs_RSyntax"><a name="267945">Number BirtMath.add( Number n1, Number n2 )</a></div>
      <p class="N_sb_ScanBold"><a name="267946">Parameters</a></p>
      <p class="RParameter"><a name="267947">n1</a></p>
      <p class="bn_BodyNoLead"><a name="267948">Number object. The first number to use in the calculation.</a></p>
      <p class="RParameter"><a name="270526">n2</a></p>
      <p class="bn_BodyNoLead"><a name="270530">The second number to use in the calculation.</a></p>
      <p class="N_sb_ScanBold"><a name="267949">Returns</a></p>
      <p class="b_Body"><a name="267950">Number object. The number that results from adding n1 and n2.</a></p>
      <p class="N_sb_ScanBold"><a name="267951">Example</a></p>
      <p class="b_Body"><a name="267952">The following example returns the sum of values in the SalesTotal and Shipping fields:</a></p>
      <div class="cf_CodeFirst"><a name="267953">BirtMath.add( row["SalesTotal"], row["Shipping"] )</a></div>
      <h3 class="RH2_Method"><a name="271050">BirtMath.ceiling</a></h3>
      <p class="b_Body"><a name="271051">This function rounds a number up, away from 0, to the nearest specified multiple.</a></p>
      <p class="N_sb_ScanBold"><a name="271052">Syntax</a></p>
      <div class="rs_RSyntax"><a name="271053">Number BirtMath.ceiling( Number n, Number significance )</a></div>
      <p class="N_sb_ScanBold"><a name="271054">Parameters</a></p>
      <p class="RParameter"><a name="271055">n</a></p>
      <p class="bn_BodyNoLead"><a name="271056">Number object. The number to round up.</a></p>
      <p class="RParameter"><a name="271057">significance</a></p>
      <p class="bn_BodyNoLead"><a name="271058">Number object. The multiple to round n to.</a></p>
      <p class="N_sb_ScanBold"><a name="271059">Returns</a></p>
      <p class="b_Body"><a name="271060">Number object. A number that results from the rounding. If n is an exact multiple of significance, no rounding occurs.</a></p>
      <p class="N_sb_ScanBold"><a name="271061">Examples</a></p>
      <p class="b_Body"><a name="271062">BirtMath.ceiling(&nbsp;) is commonly used to round up prices. For example, to avoid dealing with pennies, you can round prices in a Price field up to the nearest nickel with the following expression:</a></p>
      <div class="cf_CodeFirst"><a name="271063">BirtMath.ceiling( row["Price"] , 0.05 )</a></div>
      <p class="b_Body"><a name="271395">If the Price value is 20.52, the expression returns 20.55.</a></p>
      <p class="b_Body"><a name="271406">The following expression rounds prices up to the nearest dime:</a></p>
      <div class="cf_CodeFirst"><a name="271412">BirtMath.ceiling( row["Price"] , 0.1 )</a></div>
      <p class="b_Body"><a name="271407">If the Price value is 20.52, the expression returns 20.60. If the Price value is 20.40, the expression returns 20.40. No rounding occurs because 20.40 is a multiple of 0.1.</a></p>
      <p class="b_Body"><a name="271501">The following expression rounds prices up to the nearest dollar:</a></p>
      <div class="cf_CodeFirst"><a name="271502">BirtMath.ceiling( row["Price"] , 1 )</a></div>
      <p class="b_Body"><a name="271518">If the Price value is 20.30, the expression returns 21.</a></p>
      <h3 class="RH2_Method"><a name="270549">BirtMath.divide</a></h3>
      <p class="b_Body"><a name="270550">This function returns the result of dividing one number by another.</a></p>
      <p class="N_sb_ScanBold"><a name="270551">Syntax</a></p>
      <div class="rs_RSyntax"><a name="270552">Number BirtMath.divide( Number dividend, Number divisor )</a></div>
      <p class="N_sb_ScanBold"><a name="270553">Parameters</a></p>
      <p class="RParameter"><a name="270554">dividend</a></p>
      <p class="bn_BodyNoLead"><a name="270555">Number object. The number to be divided.</a></p>
      <p class="RParameter"><a name="270556">divisor</a></p>
      <p class="bn_BodyNoLead"><a name="270557">Number object. The number by which dividend is divided.</a></p>
      <p class="N_sb_ScanBold"><a name="270558">Returns</a></p>
      <p class="b_Body"><a name="270559">Number object. A number that results from dividing dividend by divisor.</a></p>
      <p class="N_sb_ScanBold"><a name="270560">Examples</a></p>
      <p class="b_Body"><a name="270561">The following example shows the results of dividing specific numbers:</a></p>
      <div class="cf_CodeFirst"><a name="271010">BirtMath.divide( 10, 2 ) // returns 5</a></div>
      <div class="co_Code"><a name="271019">BirtMath.divide( 2, 10) // returns 0.2</a></div>
      <p class="b_Body"><a name="271007">The following example returns the result of dividing values in the Total field by values in the Quantity field:</a></p>
      <div class="cf_CodeFirst"><a name="270562">BirtMath.divide( row["Total"], row["Quantity"] )</a></div>
      <h3 class="RH2_Method"><a name="271580">BirtMath.mod</a></h3>
      <p class="b_Body"><a name="271581">This function returns the remainder after a number is divided by a divisor.</a></p>
      <p class="N_sb_ScanBold"><a name="271582">Syntax</a></p>
      <div class="rs_RSyntax"><a name="271583">Number BirtMath.mod( Number number, Number divisor )</a></div>
      <p class="N_sb_ScanBold"><a name="271584">Parameters</a></p>
      <p class="RParameter"><a name="271585">number</a></p>
      <p class="bn_BodyNoLead"><a name="271586">Number object. The number to be divided.</a></p>
      <p class="RParameter"><a name="271587">divisor</a></p>
      <p class="bn_BodyNoLead"><a name="271588">Number object. The number by which the first number is divided. You must specify a non-zero number.</a></p>
      <p class="N_sb_ScanBold"><a name="271589">Returns</a></p>
      <p class="b_Body"><a name="271590">The remainder after number is divided by divisor.</a></p>
      <p class="N_sb_ScanBold"><a name="271591">Examples</a></p>
      <p class="b_Body"><a name="271592">The following examples shows the results that the function returns for specific numbers:</a></p>
      <div class="cf_CodeFirst"><a name="274476">BirtMath.mod( 10, 3 ) // returns 1</a></div>
      <div class="co_Code"><a name="274483">BirtMath.mod( 10, 5 ) // returns 0</a></div>
      <div class="co_Code"><a name="274514">BirtMath.mod( 10, 6 ) // returns 4</a></div>
      <p class="b_Body"><a name="274193">The following example checks if numbers in the Grade field are odd or even. When the divisor is 2, the function returns 0 for even numbers, and 1 for odd numbers.</a></p>
      <div class="cf_CodeFirst"><a name="271593">BirtMath.mod( row["Grade"], 2 ) </a></div>
      <h3 class="RH2_Method"><a name="270911">BirtMath.multiply</a></h3>
      <p class="b_Body"><a name="270913">This function returns the multiplication of two numbers. </a></p>
      <p class="N_sb_ScanBold"><a name="270914">Syntax</a></p>
      <div class="rs_RSyntax"><a name="270600">Number BirtMath.multiply( Number n1, Number n2 )</a></div>
      <p class="N_sb_ScanBold"><a name="270601">Parameters</a></p>
      <p class="RParameter"><a name="270940">n1</a></p>
      <p class="bn_BodyNoLead"><a name="270941">Number object. The first number to use in the calculation.</a></p>
      <p class="RParameter"><a name="270942">n2</a></p>
      <p class="bn_BodyNoLead"><a name="270943">Number object. The second number to use in the calculation.</a></p>
      <p class="N_sb_ScanBold"><a name="270944">Returns</a></p>
      <p class="b_Body"><a name="270945">Number object. A number that results from multiplying n1 and n2.</a></p>
      <p class="N_sb_ScanBold"><a name="270946">Example</a></p>
      <p class="b_Body"><a name="270947">The following example returns the result of multiplying values in the QuantityOrdered and PriceEach fields:</a></p>
      <div class="cf_CodeFirst"><a name="270948">BirtMath.multiply( row["QuantityOrdered"], row["PriceEach"] )</a></div>
      <h3 class="RH2_Method"><a name="274568">BirtMath.round</a></h3>
      <p class="b_Body"><a name="274569">This function rounds a number to a specified number of digits.</a></p>
      <p class="N_sb_ScanBold"><a name="274570">Syntax</a></p>
      <div class="rs_RSyntax"><a name="274571">Number BirtMath.round( Number number, Number dec )</a></div>
      <p class="N_sb_ScanBold"><a name="274572">Parameters</a></p>
      <p class="RParameter"><a name="274573">number</a></p>
      <p class="bn_BodyNoLead"><a name="274614">Number object. The number to round.</a></p>
      <p class="RParameter"><a name="274615">dec</a></p>
      <p class="bn_BodyNoLead"><a name="274616">Number object. The number of digits to round number to. If you omit this argument, the function assumes 0.</a></p>
      <p class="N_sb_ScanBold"><a name="274577">Returns</a></p>
      <p class="b_Body"><a name="274578">Number object. A number rounded to a specified number of digits.</a></p>
      <p class="N_sb_ScanBold"><a name="274579">Examples</a></p>
      <p class="b_Body"><a name="274580">The following examples shows the results that the function returns for specific numbers:</a></p>
      <div class="cf_CodeFirst"><a name="274581">BirtMath.round( 1545.50 ) // returns 1546</a></div>
      <div class="co_Code"><a name="274695">BirtMath.round( 1545.56, 1 ) // returns 1545.6</a></div>
      <div class="co_Code"><a name="274650">BirtMath.round( 1545.23, 1 ) // returns 1545.2</a></div>
      <div class="co_Code"><a name="274582">BirtMath.round( 1545.50, -1 ) // returns 1550</a></div>
      <p class="b_Body"><a name="274584">The following example rounds the values in the PriceEstimate field to return an integer:</a></p>
      <div class="cf_CodeFirst"><a name="274585">BirtMath.round( row["PriceEstimate"], 0 ) </a></div>
      <h3 class="RH2_Method"><a name="274754">BirtMath.roundDown</a></h3>
      <p class="b_Body"><a name="274755">This function rounds a number down to a specified number of digits.</a></p>
      <p class="N_sb_ScanBold"><a name="274756">Syntax</a></p>
      <div class="rs_RSyntax"><a name="274757">Number BirtMath.roundDown( Number number, Number dec )</a></div>
      <p class="N_sb_ScanBold"><a name="274758">Parameters</a></p>
      <p class="RParameter"><a name="274759">number</a></p>
      <p class="bn_BodyNoLead"><a name="274760">Number object. The number to round.</a></p>
      <p class="RParameter"><a name="274761">dec</a></p>
      <p class="bn_BodyNoLead"><a name="274762">Number object. The number of digits to round number down to. If you omit this argument, the function assumes 0.</a></p>
      <p class="N_sb_ScanBold"><a name="274763">Returns</a></p>
      <p class="b_Body"><a name="274764">Number object. A number rounded down to a specified number of digits.</a></p>
      <p class="N_sb_ScanBold"><a name="274765">Examples</a></p>
      <p class="b_Body"><a name="274766">The following examples shows the results that the function returns for specific numbers:</a></p>
      <div class="cf_CodeFirst"><a name="274767">BirtMath.roundDown( 1545.50 ) // returns 1545</a></div>
      <div class="co_Code"><a name="274768">BirtMath.roundDown( 1545.56, 1 ) // returns 1545.5</a></div>
      <div class="co_Code"><a name="274769">BirtMath.roundDown( 1545.23, 1 ) // returns 1545.2</a></div>
      <div class="co_Code"><a name="274770">BirtMath.roundDown( 1545.50, -1 ) // returns 1540</a></div>
      <p class="b_Body"><a name="274771">The following example rounds down the values in the PriceEstimate field to return an integer:</a></p>
      <div class="cf_CodeFirst"><a name="274772">BirtMath.roundDown( row["PriceEstimate"], 0 ) </a></div>
      <h3 class="RH2_Method"><a name="275084">BirtMath.roundUp</a></h3>
      <p class="b_Body"><a name="275085">This function rounds a number up to a specified number of digits.</a></p>
      <p class="N_sb_ScanBold"><a name="275086">Syntax</a></p>
      <div class="rs_RSyntax"><a name="275087">Number BirtMath.roundUp( Number number, Number dec )</a></div>
      <p class="N_sb_ScanBold"><a name="275088">Parameters</a></p>
      <p class="RParameter"><a name="275089">number</a></p>
      <p class="bn_BodyNoLead"><a name="275090">Number object. The number to round up.</a></p>
      <p class="RParameter"><a name="275091">dec</a></p>
      <p class="bn_BodyNoLead"><a name="275092">Number object. The number of digits to round number up to. If you omit this argument, the function assumes 0.</a></p>
      <p class="N_sb_ScanBold"><a name="275093">Returns</a></p>
      <p class="b_Body"><a name="275094">Number object. A number rounded up to a specified number of digits.</a></p>
      <p class="N_sb_ScanBold"><a name="275095">Examples</a></p>
      <p class="b_Body"><a name="275096">The following examples shows the results that the function returns for specific numbers:</a></p>
      <div class="cf_CodeFirst"><a name="275097">BirtMath.roundUp( 1545.50 ) // returns 1546</a></div>
      <div class="co_Code"><a name="275098">BirtMath.roundUp( 1545.56, 1 ) // returns 1545.6</a></div>
      <div class="co_Code"><a name="275099">BirtMath.roundUp( 1545.23, 1 ) // returns 1545.3</a></div>
      <div class="co_Code"><a name="275100">BirtMath.roundUp( 1545.50, -1 ) // returns 1550</a></div>
      <p class="b_Body"><a name="275101">The following example rounds up the values in the PriceEstimate field to return an integer:</a></p>
      <div class="cf_CodeFirst"><a name="275102">BirtMath.roundUp( row["PriceEstimate"], 0 ) </a></div>
      <h3 class="RH2_Method"><a name="275121">BirtMath.safeDivide</a></h3>
      <p class="b_Body"><a name="275122">This function returns the result of dividing one number by another, preventing a division by zero condition. </a></p>
      <p class="N_sb_ScanBold"><a name="275123">Syntax</a></p>
      <div class="rs_RSyntax"><a name="275124">Number BirtMath.safeDivide( Number dividend, Number divisor, object ifZero )</a></div>
      <p class="N_sb_ScanBold"><a name="275125">Parameters</a></p>
      <p class="RParameter"><a name="275126">dividend</a></p>
      <p class="bn_BodyNoLead"><a name="275127">Number object. The number to be divided.</a></p>
      <p class="RParameter"><a name="275128">divisor</a></p>
      <p class="bn_BodyNoLead"><a name="275129">Number object. The number by which dividend is divided.</a></p>
      <p class="RParameter"><a name="275490">ifZero</a></p>
      <p class="bn_BodyNoLead"><a name="275502">Object. The value to return when divisor is zero.</a></p>
      <p class="N_sb_ScanBold"><a name="275130">Returns</a></p>
      <p class="b_Body"><a name="275131">Number object. Number object. A number that results from dividing dividend by divisor.</a></p>
      <p class="N_sb_ScanBold"><a name="275132">Examples</a></p>
      <p class="b_Body"><a name="275133">The following example shows the results that the function returns for specific numbers:</a></p>
      <div class="cf_CodeFirst"><a name="275134">BirtMath.safeDivide( 10, 2, 0 ) // returns 5</a></div>
      <div class="co_Code"><a name="275520">BirtMath.safeDivide( 10, 0, 0 ) // returns 0</a></div>
      <p class="b_Body"><a name="275521">The following example returns the result of dividing values in the Revenue field by values in the Volume field. If the Volume value is 0, the function returns 0.</a></p>
      <div class="cf_CodeFirst"><a name="275517">BirtMath.safeDivide( row["Revenue"], row["Volume"], 0 )</a></div>
      <h3 class="RH2_Method"><a name="270972">BirtMath.subtract</a></h3>
      <p class="b_Body"><a name="270974">This function returns the result of subtracting one number from another.</a></p>
      <p class="N_sb_ScanBold"><a name="270975">Syntax</a></p>
      <div class="rs_RSyntax"><a name="270976">Number BirtMath.subtract( Number n1, Number n2 )</a></div>
      <p class="N_sb_ScanBold"><a name="270977">Parameters</a></p>
      <p class="RParameter"><a name="270978">n1</a></p>
      <p class="bn_BodyNoLead"><a name="270979">Number object. The number from which to subtract.</a></p>
      <p class="RParameter"><a name="270980">n2</a></p>
      <p class="bn_BodyNoLead"><a name="270981">Number object. The number to subtract from n1.</a></p>
      <p class="N_sb_ScanBold"><a name="270982">Returns</a></p>
      <p class="b_Body"><a name="270983">Number object. A number that results from subtracting n2 from n1.</a></p>
      <p class="N_sb_ScanBold"><a name="270984">Example</a></p>
      <p class="b_Body"><a name="271028">The following example shows the results of subtracting specific numbers:</a></p>
      <div class="cf_CodeFirst"><a name="271029">BirtMath.subtract( 12, 4 ) // returns 8</a></div>
      <div class="co_Code"><a name="271030">BirtMath.subtract( 4, 12) // returns -8</a></div>
      <p class="b_Body"><a name="271031">The following example returns the result of subtracting values in the Discount field from values in the Total field:</a></p>
      <div class="cf_CodeFirst"><a name="271032">BirtMath.subtract( row["Total"], row["Discount"] )</a></div>
    </blockquote>
    <hr align="left" />
    <table align="right" summary="">
      <tr>
        <td class="WebWorks_Company_Name_Bottom">
          <a href="notices.html">(c) Copyright Actuate Corporation 2013</a>
        </td>
      </tr>
    </table>
  </body>
</html>